<?php
require 'db_conn.php';
if($_POST){
    $username=$_POST['username'];
    $sex=$_POST['sex'];
    $message=$_POST['message'];
    $imgurl=$_POST['imgurl'];
    
    $sql="insert into t_message (username,sex,message,imgurl) values ('$username','$sex','$message','$imgurl')";
    
   $rs=$db->query($sql);
   if($rs){
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('留言成功！');";
        echo "window.location.href='index.php';"; 
        echo "</script>";
        exit;

   }else{
      Header("Location:index.php");
   }
   
    
}

